﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;

namespace QS.Input
{
    public static class QKeyboardOperations
    {
        private static List<Keys> m_KeysDown = new List<Keys>();
        private static List<Keys> m_KeysClicked = new List<Keys>();

        public static KeyboardState CurrentKeyboardState;

        public static KeyboardState LastKeyboardState;

        public static void UpdateKeyboardState()
        {
            LastKeyboardState = CurrentKeyboardState;

            CurrentKeyboardState = Keyboard.GetState();

            m_KeysDown.Clear();
            m_KeysDown.AddRange(CurrentKeyboardState.GetPressedKeys());
        }

        public static bool IsNewKeyPress(Keys key)
        {
            return (CurrentKeyboardState.IsKeyDown(key) &&
                        LastKeyboardState.IsKeyUp(key));

        }

        public static List<Keys> KeysDown
        {
            get
            {
                return m_KeysDown;
            }
            private set
            {
                m_KeysDown = value;
            }
        }
    }
}
